#include <iostream>
#include "qThreadPool/ThreadPool.h"
//#include "MyTask.cpp" // 示例任务
#include "qThreadPool/Task.h"
#include "qThreadPool/Thread.h"

class MyTask : public Task
{
public:
    void Run(WorkerThread *thread)
    {
        std::cout << "Task is running in thread." << std::endl;
    }

    void Release()
    {
        delete this;
    }
};

int main()
{
    ThreadPool pool;
    if (!pool.Open(4))
    {
        std::cerr << "Failed to open thread pool!" << std::endl;
        return -1;
    }
    for(int i = 0; i < 100; ++i)
    {
        pool.PostTask(new MyTask());
    }
    Thread::Sleep(20000);  // 等任务跑完（建议改为更优雅的 Join 机制）

    pool.Shutdown();
    std::cout << "All tasks completed." << std::endl;
    return 0;
}
